{extend name="common/base" /}
{block name="body"}
<main>
    <div class="img_100">
       <img src="__ROOT__/static/images/login_bg.png">
    </div>
    <div class="login_box">
       <form class="layui-form login_form" onsubmit="return false">
          <div class="form_item">
             <div class="label">用户名</div>
             <input class="layui-input" id="mobile" placeholder="请输入账号">
          </div>
          <div class="form_item">
             <div class="label">密码</div>
             <input class="layui-input" type="password" id="password" placeholder="请输入账号密码">
            
             <div class="d-flex jc-fe mt10 remenber">
                <input type="checkbox" name="AAA" title="记住密码">
             </div>
          </div>
          <div class="form_item">
             <div class="layui-btn w100" id="login_btn">登录</div>
          </div>
       </form>
    </div>
 </main>
{/block}
{block name="js"} 
<script>

    $('#login_btn').click(function() {
        var mobile          = $('#mobile').val();
        var password        = $('#password').val();
        var mobilePattern   = /^1[3-9]\d{9}$/;
        if (!mobilePattern.test(mobile)) {
           return layer.msg("手机号格式不正确");
        }
        if (password.length < 6) {
            return layer.msg("密码长度不正确至少4位");
        }
        var data =  {
            mobile: mobile,
            password: password,
        }
        ajaxRequest('/login', data, 'POST', this, function (response) {
            layer.msg('登录成功', {icon: 1, time: 2000}, function() {
                // 弹窗消失后跳转
                window.location.href = '/index'; // 替换为目标页面的 URL
            });
        });
    })
</script>
{/block}
